﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuoteOfTheDay;

namespace QuoteOfTheDayGUI
{
    public partial class mainForm : Form
    {
        private Quote quote;

        public mainForm()
        {
            InitializeComponent();
            quote = new Quote();
            quote.QuotePublished += new NewQuotePublishedHandler(quote_QuotePublished);
        }

        void quote_QuotePublished(object sender, EventArgs e)
        {
            txtNewQuote.Text = string.Empty;
            txtQuote.Text = quote.CurrentQuote.Message;
            txtDatePosted.Text = quote.CurrentQuote.QuotePostedOn.ToShortDateString();
            Refresh();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            quote.AddQuote(new Quote(txtNewQuote.Text));
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            quote.RemoveQuote(quote.CurrentQuote);
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            quote.RefreshQuote();
        }
    }
}
